package com.guangaiboen.attendance.wx.service;

import com.guangaiboen.attendance.db.service.AttendanceRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author zhy
 * @date 2019-01-17 23:07
 **/
@Component
public class GetRegionService {

	@Autowired
	private AttendanceRegionService regionService;

	private static List<com.guangaiboen.attendance.db.domain.AttendanceRegion> attendanceRegions;

	protected List<com.guangaiboen.attendance.db.domain.AttendanceRegion> getAttendanceRegions() {
		if(attendanceRegions==null){
			createRegion();
		}
		return attendanceRegions;
	}

	private synchronized void createRegion(){
		if (attendanceRegions == null) {
			attendanceRegions = regionService.getAll();
		}
	}
}
